<template>
	<view>
		<view >
			<view style="width: 100%; margin-top: 10rpx;">
			<!-- 	<image src="https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/sd-title.png"
					style="width: 100%; height: 300rpx; border-radius: 20rpx;" mode=""></image> -->
					<view style=" color: white;background-color: #0042f4; width: 100%; height: 250rpx; border-radius: 20rpx; font-size: 30rpx; line-height: 35px;">
						<uni-row>
							<uni-col :span="8" >
								<view style=" display: flex; justify-content: center;  align-items: center;">宿舍未打卡</view>
							</uni-col>
							<uni-col :span="8" >
								<view style=" display: flex; justify-content: center;  align-items: center;">周末未打卡</view>
							</uni-col>
							<uni-col :span="8">
								<view  style=" display: flex; justify-content: center;  align-items: center;">滞留人数</view>
							</uni-col>
						</uni-row>
						<uni-row>
							<uni-col :span="8"  >
									<view style=" display: flex; justify-content: center;  align-items: center;" @click="toDormitoryAttenceDetail('dormitory')">{{boardData.dormitorySummary}}</view>
							</uni-col>
							<uni-col :span="8" >
									<view style=" display: flex; justify-content: center;  align-items: center;" @click="toDormitoryAttenceDetail('weekend')">{{boardData.weekendSummary}}</view>
							</uni-col>
							<uni-col :span="8" >
								<view style=" display: flex; justify-content: center;  align-items: center;" @click="toRetentionCount()">{{boardData.retentionSummary}}</view>
							</uni-col>
						</uni-row>
						<uni-row>
							<uni-col :span="8">
								<view  style=" display: flex; justify-content: center;  align-items: center;">早操未到</view>
							</uni-col>
							<uni-col :span="8">
								<view  style=" display: flex; justify-content: center;  align-items: center;">白天违纪</view>
							</uni-col>
							<uni-col :span="8" >
								<view style=" display: flex; justify-content: center;  align-items: center;">晚上违纪</view>
							</uni-col>
						</uni-row>
						<uni-row>
							<uni-col :span="8" >
								<view  style=" display: flex; justify-content: center;  align-items: center;" @click="toMorningExercisesCount()">{{boardData.morningSummary}}</view>
							</uni-col>
							<uni-col :span="8" >
								<view  style=" display: flex; justify-content: center;  align-items: center;">{{boardData.dayViolationSummary}}</view>
							</uni-col>
							<uni-col :span="8">
								<view  style=" display: flex; justify-content: center;  align-items: center;">{{boardData.nightViolationSummary}}</view>
							</uni-col>
						</uni-row>
					</view>
			</view>
			<view style="margin-top:30rpx;font-size: 38rpx;" class="Teacher">
		<!-- 		<view v-for="(item,index) in managArr" :key="index" @click="manageSkip(index)">
					<view :class="index%2==0 ? 'indexManage':'indexManage1'">
						<view style="margin-left:60upx">{{managArr[index]}}</view>
						<view class="manageIndexFont">
							<view style="font-size: 36rpx;" class="iconfont icon-shouye-shouye"></view>
							<view class="manageLine" style="margin:30rpx 0rpx;"></view>
							<view style="font-size: 24rpx;">点击查看</view>
						</view>
					</view>

				</view> -->
				

				
				<view v-for="(item,index) in managArr" :key="index" style="text-align: center;">
					<view style="width: 200rpx;" @click="manageSkip(item)">
						<div style="margin: 20rpx 20rpx 40rpx 20rpx;position: relative;">
							<div v-if="index==5" class="num">{{count}}</div>
							<image :src="item.img" style="width: 130rpx;height: 130rpx;"></image>
							<view style="font-size: 14px;">{{item.indexName}}</view>
						</div>
					</view>
				</view>
				<view v-if="isDuty==1" class="attdenanceSty" @click="goBackIndex()">
					<view style="text-align: center;width:605rpx;font-size: 38rpx;">返回值班界面</view>
				</view>
			</view>
			
		</view>

	</view>
</template>

<script>
	import bottomCom from '../component/bottom.vue'
	// import topCom from '../component/topCom.vue'
	import manageTeacher from '@/api/modules/managementTeacher.js'
	export default {
		name: 'manangement',
		data() {
			return {
				boardData: {
					dayViolationSummary: 0,
					dormitorySummary: 0,
					morningSummary: 0,
					nightViolationSummary: 0,
					retentionSummary: 0,
					weekendSummary: 0
				},
				roleName: '',
				isDuty: 0,
				userName: '',
				userRole: '',
				userId: '',
				operateType: '',
				datetime: '',
				topName: '首页',
				managArr:
				   [{
						icon: '',
						indexName: '宿舍考勤',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/kejs.png',
					},
					{
						icon: '',
						indexName: '周末考勤',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/kets.png',
					}, {
						icon: '',
						indexName: '宿舍数据',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/dor.png',
					}, {
						icon: '',
						indexName: '班级数据',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/baox.png',
					},
					// , {
					// 	icon: '',
					// 	indexName: '宿舍请假旧',
					// 	img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/wanzx.png',
					// }
					
					// {
					// 	icon: '',
					// 	indexName: '待处理异常',
					// 	img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/wuxiu.png',
					// },
					{
						icon: '',
						indexName: '值班数据',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/banjiguanli.png',
					},
					// {
					// 	icon: '',
					// 	indexName: '宿舍请假',
					// 	img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/xueshengqingjia.png',
					// },
					{
						icon: '',
						indexName: '上机数据',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/xueshengkaoqin.png',
					},
					{
						icon: '',
						indexName: '待处理任务',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/daichulirenwu.png',
					},
					{
						icon: '',
						indexName: '宿舍卫生',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/daichulirenwu.png',
					},
					{
						icon: '',
						indexName: '滞留统计',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/daichulirenwu.png',
					},
					{
						icon: '',
						indexName: '早操统计',
						img: 'https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/daichulirenwu.png',
					}
				],
				mangBottomArr: [{
						name: 'home',
						icon: 'iconfont icon-yonghutongji',
						text: "考勤",
						path: '/pages/classManagement/classManagementIndex'
					},
					{
						name: 'atttendance',
						icon: 'iconfont icon-bi',
						text: "统计",
						path: '/pages/classManagement/classManagementIndex'
					},
					{
						name: 'maintenance',
						icon: 'iconfont icon-shezhi',
						text: "设置",
						path: '/pages/classManagement/classManagementIndex'
					},
				]
			}
		},
		components: {
			// topCom,
			bottomCom
		},
		onShow() {
			var that = this
			uni.getStorage({
				key: "isDuty",
				success: (res) => {
					that.isDuty = res.data
				}
			})
			uni.getStorage({
				key: "userInfo",
				success: (res) => {
					// that.userName = res.data
					let roleName = res.data
					this.roleName = roleName
					console.log(roleName, 666)
				}
			})
			uni.getStorage({
				key: "userRole",
				success: (res) => {
					that.userName = res.data
					let roleName = res.data
					this.roleName = roleName
					console.log(roleName, 666)
				}
			})
		},
		onLoad(options) {
			this.userRole = options.userRole
			this.userId = uni.getStorageSync("loginId");
			
			this.userName = uni.getStorageInfoSync("userRole")
			this.getBoardData();
		},
		methods: {
			toRetentionCount() {
				uni.navigateTo({
					url:`/pages_duty/classTeacher/retention/retentionCount`
				})
			},
			toMorningExercisesCount() {
				uni.navigateTo({
					url:`/pages_duty/classTeacher/morningExercises/morningExercisesCount`
				})
			},
			toDormitoryAttenceDetail(operateType) {
				this.operateType = operateType
				  const today = new Date();
				  const yesterday = new Date(today);
				  if(operateType == 'dormitory'){
						yesterday.setDate(yesterday.getDate() - 1);
				  }
				this.datetime = yesterday.toISOString().split('T')[0];
				console.log(this.datetime)
				uni.navigateTo({
					url:`/pages_duty/dormitoryUnclockRecord/dormitoryAttenceSummary?userId=${this.userId}&dateTime=${this.datetime}&operateType=${this.operateType}`
				})
			},
			getBoardData() {
				manageTeacher.getBoardData(this.userId).then(res => {
					this.boardData = res.data	
				}).catch(e => {
		
				})
			},
			goBackIndex() {
				uni.navigateTo({
					url: '/pages_duty/dutyCheckWorkAttendance/dutyIndex/dutyIndex'
				})
			},
			manageSkip(index) {
				if (index.indexName == '班级数据') {
					uni.navigateTo({
						url: '/pages/classManagement/classManagement',
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				} else if (index.indexName == '宿舍数据') {
					uni.navigateTo({
						url: "/pages/classManagement/classManagementDormitoryAttendance?buildingNo=畔湖苑&type=考勤",
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				} else if (index.indexName == '值班巡查处理') {
					uni.navigateTo({
						url: "/pages/classManagement/classManagduty",
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				} else if (index.indexName == '值班数据') {
					uni.navigateTo({
						url: '/pages/record/recordIndex',
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}  else if (index.indexName == '宿舍考勤') {
					uni.navigateTo({
						url: '/pages_duty/dormitoryUnclockRecord/attenceDatePicker?type=dormitory',
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				} else if (index.indexName == '周末考勤') {
					uni.navigateTo({
						url: '/pages_duty/dormitoryUnclockRecord/attenceDatePicker?type=weekend',
						success: res => {},
						fail: () => {},
						complete: () => {}
					});
				}else if (index.indexName == '上机数据') {
					uni.navigateTo({
						url: '/pages/record/pcRecode',
						
					});
				}else if (index.indexName == '待处理任务') {
					uni.navigateTo({
						url: '/pages/classManagement/departmentManagerPendingTasks/departmentManagerPendingTasks',
						
					});
				}else if (index.indexName == '宿舍卫生') {
					uni.navigateTo({
						url: '/pages_duty/dormitoryHygiene/HygieneCount',
						
					});
				}else if (index.indexName == '滞留统计') {
					uni.navigateTo({
						url: '/pages_duty/retention/retentionCount',
						
					});
				}else if (index.indexName == '早操统计') {
					uni.navigateTo({
						url: '/pages_duty/morningExercises/morningExercisesCount',
						
					});
				}
			}
		}
	}
</script>

<style>
	.indexContent {
		height: 100vh;
		/* position: relative; */
	}

	.logoSty {
		position: absolute;
		z-index: 999;
		bottom: 50rpx;
	}

	.manageLine {
		width: 100rpx;
		height: 2rpx;
		border: 1rpx solid white;
		background-color: white;
	}

	.manageIndexFont {
		display: flex;
		text-align: end;
		justify-content: flex-start;
		align-content: flex-end;
		flex-direction: column;
		padding-right: 30rpx;
		padding-top: 30rpx;
	}

	.indexManage {
		margin: auto;
		margin-top: 40upx;
		width: 582rpx;
		height: 200rpx;
		display: flex;
		justify-content: space-between;
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/T-2.png);
		background-size: 100%;
		color: white;
		padding-top: 30upx;
		font-size: 42rpx;
		background-repeat: no-repeat;
	}

	.indexManage4 {
		margin: auto;
		margin-top: 40upx;
		width: 582rpx;
		height: 200rpx;
		display: block;
		justify-content: space-between;
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/T-2.png);
		background-size: 100%;
		color: white;
		padding-top: 30upx;
		font-size: 42rpx;
		background-repeat: no-repeat;
	}

	.indexManage1 {
		margin: auto;
		margin-top: 40upx;
		width: 582rpx;
		height: 200rpx;
		display: flex;
		justify-content: space-between;
		background-image: url(https://tj-1305380059.cos.ap-nanjing.myqcloud.com/pic/T-3.png);
		background-size: 100%;
		background-repeat: no-repeat;
		color: white;
		padding-top: 30upx;
		font-size: 42rpx;
		/* opacity: 0.8; */
	}
	
	.Teacher {
		display: flex;
		align-items: center;
		justify-content: center;
		flex-wrap: wrap;
		margin: 60rpx;
	}
</style>
